import 'dart:async';

import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:jm_flutter/jm_flutter.dart';

import '../common/common.dart';
import '../common/config.dart';

///首次使用
bool get isFirstUse => GetStorage().read("isFirstUse") ?? true;

setFirstUse() => GetStorage().write("isFirstUse", false);

AppController get findApp {
  try {
    return Get.find<AppController>();
  } catch (e) {
    logd("AppController", "未初始化AppController");
    return putApp;
  }
}

AppController get putApp => Get.put(AppController(), permanent: true);

class AppController extends GetxController {
  final tag = "AppController";
  final gs = GetStorage();

  var isConnected = false.obs;
  var isDebug = G_debug.obs;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    logd(tag, "onInit");

    ever(isConnected, (value) {
      logd(tag, "isConnected改变:" + value.toString());
    });

    Timer.periodic(const Duration(seconds: 1), (timer) async {});
  }
}
